<?php
/**
 * Created by PhpStorm.
 * User: lcz
 * Date: 2018/6/23
 * Time: 9:38
 * 文章控制器
 */

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

class Article extends Api{
	
	protected $noNeedLogin = ['*'];
	protected $noNeedRight = ['*'];
	
	
	/**
	 * 文章详情
	 * @throws \think\db\exception\DataNotFoundException
	 * @throws \think\db\exception\ModelNotFoundException
	 * @throws \think\exception\DbException
	 */
	public function detail(){
		$id = input('post.id');
		if(!$id) {
			$this->error('参数错误');
		}
		
		$model = new \app\common\model\Article();
		$data = $model->find($id);
		$this->success('查询成功', $data);
	}
	
	/**
	 * 关于我们
	 * @throws \think\db\exception\DataNotFoundException
	 * @throws \think\db\exception\ModelNotFoundException
	 * @throws \think\exception\DbException
	 */
	public function about(){
		$model = new \app\common\model\Article();
		$data = $model->where(['category_id' => 15])->find();
		$this->success('查询成功', $data);
	}
	
	/**
	 * v客咨讯
	 */
	public function vk(){
		$model = new \app\common\model\Article();
		$data = $model->getCategoryArticle(19);
		$this->success('查询成功', $data);
	}
}
